import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmailVO, EmailForm, EmailQuery } from '@/api/swimming/email/types';

/**
 * 查询邮箱管理列表
 * @param query
 * @returns {*}
 */

export const listEmail = (query?: EmailQuery): AxiosPromise<EmailVO[]> => {
  return request({
    url: '/swimming/email/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询邮箱管理详细
 * @param id
 */
export const getEmail = (id: string | number): AxiosPromise<EmailVO> => {
  return request({
    url: '/swimming/email/' + id,
    method: 'get'
  });
};

/**
 * 新增邮箱管理
 * @param data
 */
export const addEmail = (data: EmailForm) => {
  return request({
    url: '/swimming/email',
    method: 'post',
    data: data
  });
};

/**
 * 修改邮箱管理
 * @param data
 */
export const updateEmail = (data: EmailForm) => {
  return request({
    url: '/swimming/email',
    method: 'put',
    data: data
  });
};

/**
 * 删除邮箱管理
 * @param id
 */
export const delEmail = (id: string | number | Array<string | number>) => {
  return request({
    url: '/swimming/email/' + id,
    method: 'delete'
  });
};
